<%@ page contentType="text/html; charset=UTF-8"%>

<!DOCTYPE html>
<!--[if IE 9 ]><html class="ie9"><![endif]-->
    <head>
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
        <meta name="format-detection" content="telephone=no">
        <meta charset="UTF-8">

        <meta name="description" content="">
        <meta name="keywords" content="">

        <title></title>
            
        <!-- CSS -->
        <link href="/ynrfinance/static/css/bootstrap.min.css" rel="stylesheet">
        <link href="/ynrfinance/static/css/animate.min.css" rel="stylesheet">
        <link href="/ynrfinance/static/css/font-awesome.min.css" rel="stylesheet">
        <link href="/ynrfinance/static/css/form.css" rel="stylesheet">
        <link href="/ynrfinance/static/css/calendar.css" rel="stylesheet">
        <link href="/ynrfinance/static/css/style.css" rel="stylesheet">
        <link href="/ynrfinance/static/css/icons.css" rel="stylesheet">
        <link href="/ynrfinance/static/css/generics.css" rel="stylesheet">
        <style>
        .control_panel_active span{
		    color: #FFD600;
		}
		
		.control_panel_active small{
		    color: #FFD600;
		}
		.control_panel_active{
			background: rgba(0,0,0,0.6);
		}
        </style>
    </head>
    <body id="skin-cloth">
        <header id="header" class="media">
            <a href="" id="menu-toggle"></a> 
            <a class="logo pull-left" href="/ynrfinance/home">尤耐锐数据科技</a>
            <div class="media-body">
                <div class="media" id="top-menu">
                    <div id="time" class="pull-right">
                        <span id="hours"></span>
                        :
                        <span id="min"></span>
                        :
                        <span id="sec"></span>
                    </div>
                </div>
            </div>
        </header>
        
        <div class="clearfix"></div>
        
        <section id="main" class="p-relative" role="main">
            <!-- Sidebar -->
            <aside id="sidebar">
                <!-- Sidbar Widgets -->
                <div class="side-widgets overflow">
                    <!-- Profile Menu -->
                    <div class="text-center s-widget m-b-25 dropdown" id="profile-menu">
                        <a href="" data-toggle="dropdown">
                            <img class="profile-pic animated" src="/ynrfinance/static/img/but.png" alt="">
                        </a>
                        <ul class="dropdown-menu profile-menu">
                            <li><a href="javascript:void(0);" class='logout_btn'>退出登录</a></li>
                        </ul>
                        <h4 class="m-0">系统管理员</h4>
                    </div>
                    
                    <!-- Calendar -->
                    <div class="s-widget m-b-25">
                        <div id="sidebar-calendar"></div>
                    </div>
                </div>
                
                <!-- Side Menu -->
                <ul class="list-unstyled side-menu">
                    <li>
                        <a class="sa-side-home" href="/ynrfinance/home">
                            <span class="menu-item">主页</span>
                        </a>
                    </li>
                    <li class="dropdown active">
                        <a class="sa-side-form" href="">
                            <span class="menu-item">发票</span>
                        </a>
                        <ul class="list-unstyled menu-item">
                            <li><a href="/ynrfinance/pendingInvoice">待处理发票</a></li>
                            <li><a href="/ynrfinance/invoiceUpload">发票上传</a></li>
                            <li><a class="active" href="/ynrfinance/invoiceEnter">手工录入</a></li>
                        </ul>
                    </li>
                </ul>

            </aside>
        
            <!-- Content -->
            <section id="content" class="container">                
                <!-- Breadcrumb -->
                <ol class="breadcrumb hidden-xs">
                    <li><a href="#">主页</a></li>
                </ol>
                
                <h4 class="page-title">控制面板</h4>
                                
                <!-- Shortcuts -->
                <div class="block-area shortcut-area">
                    <a class="shortcut tile" href="/ynrfinance/pendingInvoice">
                        <span class="icon">&#61698;</span>
                        <small class="t-overflow">待处理发票</small>
                    </a>
                    <a class="shortcut tile" href="/ynrfinance/invoiceUpload">
                        <span class="icon">&#61787;</span>
                        <small class="t-overflow">发票上传</small>
                    </a>
                    <a class="shortcut tile" href="/ynrfinance/salesUpload">
                        <span class="icon">&#61787;</span>
                        <small class="t-overflow">销售清单上传</small>
                    </a>
                    <a class="shortcut tile" href="/ynrfinance/invoiceEnter">
                        <span class="icon">&#61706;</span>
                        <small class="t-overflow">手工录入</small>
                    </a>
                    <a class="shortcut tile control_panel_active" href="/ynrfinance/claimingExpenses">
                        <span class="icon">&#61840;</span>
                        <small class="t-overflow">报销费用</small>
                    </a>
                    <a class="shortcut tile" href="/ynrfinance/bankUpload">
                        <span class="icon">&#61814;</span>
                        <small class="t-overflow">银行对账单上传</small>
                    </a>
                    <a class="shortcut tile" href="/ynrfinance/salaryUpload">
                        <span class="icon">&#61700;</span>
                        <small class="t-overflow">工资表上传</small>
                    </a>
                    <a class="shortcut tile" href="/ynrfinance/auditVoucher">
                        <span class="icon">&#61900;</span>
                        <small class="t-overflow">审核凭证</small>
                    </a>
                    <a class="shortcut tile" href="/ynrfinance/voucher">
                        <span class="icon">&#61788;</span>
                        <small class="t-overflow">查看凭证</small>
                    </a>
                    <a class="shortcut tile" href="/ynrfinance/trial">
                        <span class="icon">&#61932;</span>
                        <small class="t-overflow">科目余额表</small>
                    </a>
                    <a class="shortcut tile" href="/ynrfinance/sheet">
                        <span class="icon">&#61769;</span>
                        <small class="t-overflow">基础报表</small>
                    </a>
                </div>
                <div class="clearfix"></div>
                <hr class="whiter" style="margin-bottom:15px;"/>
                <div id="error_tips"></div>
                <div class="message-list list-container" style="padding:15px">
                	<div class="row">
                        <div class="col-md-3 m-b-15">
                            <!-- <label>Date</label> -->
                            <input type="text" id="amount" class="input-sm form-control mask-date" placeholder="金额" autocomplete="off">
                        </div>
                        <div class="col-md-3 m-b-15">
                            <input type="text" id="bill_date" class="input-sm form-control mask-time" placeholder="会计期间（如201908）" autocomplete="off">
                        </div>
                        <div class="col-md-3 m-b-15">
                            <input type="text" id="department" class="input-sm form-control mask-date_time" placeholder="报销部门  (选填)" autocomplete="off">
                        </div>
                        <div class="col-md-3 m-b-15">
                            <input type="text" id="tax" class="input-sm form-control mask-cep" placeholder="税额  (非增值税专用发票不用填)" autocomplete="off">
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-3 m-b-15">
                            <select id="company_id" data-placeholder="选择公司..." class="tag-select-limited" multiple></select>
                        </div>
                        <div class="col-md-3 m-b-15">
                            <select id="expense_type" class="select" style="display: none;">
                                <option value="9999">费用类型...</option>
                                <option value="差旅费">差旅费</option>
                                <option value="餐饮费">餐饮费</option>
                                <option value="交通费">交通费</option>
                                <option value="网络费">网络费</option>
                            </select>
                        </div>
                        <div class="col-md-3 m-b-15">
                        	<button class="btn btn-alt" style="height: 30px;font-size: 10px;width: 100%" onclick="addExpenses()">点击上传</button>
                        </div>
                    </div>
                </div>
            </section>
        </section>
        
        <!-- Javascript Libraries -->
        <!-- jQuery -->
        <script src="/ynrfinance/static/js/jquery.min.js"></script> <!-- jQuery Library -->
        <script src="/ynrfinance/static/js/jquery-ui.min.js"></script> <!-- jQuery UI -->
        <script src="/ynrfinance/static/js/jquery.easing.1.3.js"></script> <!-- jQuery Easing - Requirred for Lightbox + Pie Charts-->
        <!-- Bootstrap -->
        <script src="/ynrfinance/static/js/bootstrap.min.js"></script>
        <!--  Form Related -->
        <script src="/ynrfinance/static/js/icheck.js"></script> <!-- Custom Checkbox + Radio -->
        <!-- UX -->
        <script src="/ynrfinance/static/js/scroll.min.js"></script> <!-- Custom Scrollbar -->
        <!-- Other -->
        <script src="/ynrfinance/static/js/select.min.js"></script> <!-- Custom Select -->
        <script src="/ynrfinance/static/js/chosen.min.js"></script> <!-- Custom Multi Select -->
        <script src="/ynrfinance/static/js/calendar.min.js"></script><!-- Calendar -->
        <!-- All JS functions -->
        <script src="/ynrfinance/static/js/functions.js"></script>
        <script src="/ynrfinance/static/js/common.js"></script>
        <script type="text/javascript">
	       	$.post('/ynrfinance/getAllCompany', {}, function(data) {
	       		var companyList = data.data;
	       		for(var i in companyList) {
	       			console.log(companyList[i].id + ":" + companyList[i].name);
	       			$('.tag-select-limited')[0].add(new Option(companyList[i].name, companyList[i].id));
	       		}
	       		$(".tag-select-limited").trigger("chosen:updated");
	       		$(".tag-select-limited").chosen();
	       	});
	       	function addExpenses() {
	       		var amount = $('#amount').val();
	       		var bill_date = $('#bill_date').val();
	       		var department = $('#department').val();
	       		var tax = $('#tax').val();
	       		var company_id = $('#company_id').val()[0];
	       		var expense_type = $('#expense_type').val();
	       		if(amount == '') {
	       			$('#error_tips').html("<div class='alert alert-danger alert-dismissable fade in'>" +
                			"<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>" +
                			"需输入金额！"+
            				"</div>");
	       			return;
	       		}
	       		if(bill_date == '') {
	       			$('#error_tips').html("<div class='alert alert-danger alert-dismissable fade in'>" +
                			"<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>" +
                			"需输入会计期间！"+
            				"</div>");
	       			return;
	       		}
	       		if(company_id == null) {
	       			$('#error_tips').html("<div class='alert alert-danger alert-dismissable fade in'>" +
                			"<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>" +
                			"需选择公司！"+
            				"</div>");
	       			return;
	       		}
	       		if(expense_type == '9999' || expense_type == '') {
	       			$('#error_tips').html("<div class='alert alert-danger alert-dismissable fade in'>" +
                			"<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>" +
                			"需选择费用类型！"+
            				"</div>");
	       			return;
	       		}
	       		$.post('/ynrfinance/addExpense', 
       				{
       					amount : amount,
       					bill_date : bill_date,
       					department : department,
       					tax : tax,
       					company_id : company_id,
       					expense_type : expense_type
       				}, 
       				function(data) {
       					if(data.errorCode == '0000') {
       						window.location.reload();
       					}
       				}
	       		);
	       	}
		</script>
    </body>
</html>